<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>#(tablemeta.remarks)表单</title>
  <link rel="stylesheet" href="${ctx}/static/admin/layui/css/layui.css">
  </head>
  <body>
  	<div class="layui-card-body">
  	<form class="layui-form layui-form-pane">
	  <input name="#(classNameSmall).id" type="hidden" value="${item.id! }" />
	  #for(x : tablemeta.columnMetas)
	  <div class="layui-row">
	    <div class="layui-col-xs12">
	      <div class="layui-form-item">
	        <label class="layui-form-label">#(x.remarks)</label>
	        <div class="layui-input-block">
		      <input type="text" name="#(classNameSmall).#(x.name)" lay-verify="required" placeholder="请输入#(x.remarks)" autocomplete="off" class="layui-input" value="${item.#(x.name)!}">
		    </div>
	      </div>
	    </div>
	  </div>
	  #end
   	  <div class="layui-form-item" style="display: none">
     	<div class="layui-input-block">
       	  <button id="submit-btn" class="layui-btn" lay-submit >立即提交</button>
          <button id="reset-btn" type="reset" class="layui-btn layui-btn-primary">重置</button>
   	    </div>
   	  </div>
	</form>
	</div>
  </body>
</html>
<script src="${ctx}/static/admin/layui/layui.js"></script>
<script>
var table;
var params;
layui.use(['jquery','form'], function(){
  var $ = jQuery = layui.$;
  var form = layui.form;
  
  form.on('submit', function(data){
	  $.post('${ctx}/#(classNameSmall)/save', data.field, function(result) {
			if (result.success) {
				if (params.name == undefined) {
					table.reload({});
			    } else {
			        table.reload({
					  where:{
						  name : params.name
					  },
					  page: {
						  curr: params.curr
					  }
				    });
			    }
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
			} else {
				layer.msg(result.msg);
			}
		}, 'json');
	  return false;
  });
});
</script>
